package com.yinhe.music.yhmusic.localmusic.adapter;

import android.support.annotation.Nullable;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.yinhe.music.common.GlideHelper.GlideHelper;
import com.yinhe.music.yhmusic.R;
import com.yinhe.music.yhmusic.model.AlbumInfo;
import com.yinhe.music.yhmusic.model.Music;
import com.yinhe.music.yhmusic.utils.MusicUtils;

import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author hasee
 * @date 2017/8/15
 */

public class LocalAlbumAdapter extends BaseQuickAdapter<AlbumInfo, BaseViewHolder> {
    private List<Music> musicList;
    public LocalAlbumAdapter(@Nullable List<AlbumInfo> data,List<Music> musicList ) {
        super(R.layout.local_album_item, data);
        this.musicList = musicList;
    }

    @Override
    protected void convert(BaseViewHolder helper, AlbumInfo item) {
        helper.setText(R.id.album_name,item.getAlbumName());
        int songSum = MusicUtils.getAlbumSong(musicList,item.getAlbumId()).size();
        helper.setText(R.id.album_num,songSum + "首");
        ImageView image = helper.getView(R.id.album_image);
        GlideHelper.setImageResource(image,item.getImage(),R.drawable.default_cover);
    }
}
